﻿using System.Windows;
using System;

namespace Silverlight.InputCtrl
{
    /// <summary>
    /// Interface to all validator controls
    /// </summary>
    public interface IBaseValidator
    {
        /// <summary>
        /// Property with last result of validation
        /// </summary>
        bool IsValidResult { get; }

        /// <summary>
        /// Enabled / Disabled the validation
        /// </summary>
        bool Enabled { get; set; }

        /// <summary>
        /// FrameworkElement will be validated
        /// </summary>
        FrameworkElement ElementValidator { get; }

        /// <summary>
        /// last internal Exception 
        /// </summary>
        Exception ExceptionValidator { get; }

        /// <summary>
        /// Error Message To Display when validation fails
        /// </summary>
        string ErrorMessage { get; set; }

        /// <summary>
        /// Name of the group to validate
        /// </summary>
        string Group { get; set; }

        /// <summary>
        /// Initialize validator
        /// </summary>
        /// <param name="nameElement">FrameworkElement will be validated</param>
        /// <param name="propertyName">Name of property that will be used to validate</param>
        void InitValidator(FrameworkElement nameElement, string propertyName);
        
        /// <summary>
        /// Validation method
        /// </summary>
        /// <returns>True if value accepted by the condition</returns>
        bool Validate();

        /// <summary>
        /// Perform Reset action (Set IsValidResult  to false);
        /// </summary>
        void Reset();

        /// <summary>
        /// Name of the property to validate
        /// </summary>
        /// <remarks>
        /// Overrider PropertyToValidate property in ColletionValidators
        /// </remarks>
        string PropertyToValidate { get; set; }
    }
}
